<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-wcs__pc}">
      <wcs-form v-model="dataForm" :formList="formList" :table-column="tableColumn" :advanced="advanced"
        @check-change="checkChange" @changeAdvance="changeAdvance" @getDataList="getDataList" @getReset="getReset">
      </wcs-form>
      <wcs-table ref="wcsTable" class="pcItem" v-model="dataForm" :page="page" :total="total" :limit="limit"
        :tableData="dataList" :table-column="column" :module-options="mixinViewModuleOptions" @addOrUpdateHandle="addOrUpdateHandle"
        :dataListLoading="dataListLoading" :showSelection="true" @pageSizeChangeHandle="pageSizeChangeHandle"
        @pageCurrentChangeHandle="pageCurrentChangeHandle" @selectChangeHandle="selectChangeHandle" />
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from "@/mixins/view-module";
import AddOrUpdate from "./components/pc-add-or-update";
import { formList, tableColumn } from './config'
import wcsTable from '@/components/wcs-table'
import wcsForm from '@/components/wcs-form'
export default {
  mixins: [mixinViewModule],
  data() {
    return {
      mixinViewModuleOptions: {
        getDataListURL: "/wcs/pc-item/page",
        getDataListIsPage: true,
      },
      dataForm: {
        id: '',
        itemNo: '',
        itemName: '',
        itemAdr: ''
      },
      id: '',
      formList,
      tableColumn,
      column: [],
      advanced: false
    };
  },
  components: {
    AddOrUpdate,
    wcsTable,
    wcsForm
  },
  methods: {
    //0.重置搜索框
    getReset() {
      this.dataForm = this.$options.data().dataForm;
    },
    // 单选
    selectChangeHandle(selection, row) {
      this.id = ''; //每次单选都重置id
      if (selection.length > 1) {
        this.$refs.wcsTable.$refs.Table.clearSelection()
        this.$refs.wcsTable.$refs.Table.toggleRowSelection(row)
      }
      if (selection.length != 0) {
        //只有当真正选中了目标主单才获取id
        this.id = row.id;
      }
    }
  },
};
</script>
<style lang="scss" scoped>
/* 隐藏表头的全选框 */
::v-deep .stnMapping thead .el-table-column--selection .cell {
  display: none;
}
</style>
<style>
.right-handle-group {
  float: right;
}
</style>
